{extend name="base" /}
{block name="css"}
{css href="__CSS__/pay.css" /}
{/block}
{block name="body"}
<!-- 主要内容 开始 -->
<div class="weui-tab__bd-item">
  <header class="weui-navBar weui-navBar-fixed">
    <a href="javascript:history.go(-1);" class="weui-navBar-item">
      <i class="icon iconfont icon-fanhui"></i>
    </a>
    <div class="weui-center">
      <span class="weui-center-title">转入</span>
    </div>
    <a href="deposit_log.html" class="weui-navBar-item">
      账单
    </a>
  </header>
  <div class="weui-cells weui-cells_form">
    <div class="weui-cell">
      <div class="weui-cell__hd"><label for="date" class="weui-label">转入方式</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" id="payment" type="text" value="零钱" readonly data-values="001">
      </div>
    </div>
    <div class="divHeight"></div>
    <div class="weui-pay-inner">
      <h1 class="weui-pay-title">转入金额(元)</h1>
      <div class="weui-pay-input"> <strong class="weui-pay-strong">￥</strong>
        <input type="number" name="money" class="weui-pay-inputs" placeholder="请输入金额">
      </div>
      <div class="weui-pay-intro">零钱余额￥<b>{$info.money|default="0.00"}</b>,<span class="f-blue">全部转入</span>
      </div>
    </div>
    <div class="weui-btn-area">
        <a href="javascript:;" class="weui-btn weui-btn_primary" style="display: none;">立即支付</a>
    </div>
  </div>

</div>
<!-- 主要内容 结束 -->
<audio id="bgMusic" src="__IMG__/glod.mp3" preload="load"></audio>
{/block}
{block name="js"}
<script type="text/javascript">
  $(function(){ 
    $('.f-blue').click(function() { //全部转入
      $(".weui-pay-inputs").val($(this).prev().text());
      if ($(".weui-pay-inputs").val()>0) $('.weui-btn').show();
    });
    $("#payment").select({
      title: "选择转入方式",
      items: [
        {
          title: "零钱",
          value: "001",
        },
        {
          title: "招商银行",
          value: "002",
        },
        {
          title: "建设银行",
          value: "003",
        }
      ],
      onChange: function(data){
        var values = data.values;
        if (values != 001) return $('.weui-pay-intro').hide();
        $('.weui-pay-intro').show();
      }

    });
    /*失去焦点触发*/
    $(".weui-pay-inputs").blur(function(){
      if ($('#payment').data('values')==001)  if ($(this).val()>0 && $(this).val()<= $('b').text()) $('.weui-btn').show();
      if ($(this).val()>0) $('.weui-btn').show();

    })
    $('.weui-btn_primary').click(function() {
      var num = $('.weui-pay-inputs').val();
      // if(!is_weixin()) $.toptip('请在微信中进行充值！','error');
      if(!num || !/^(([1-9]\d*)|\d)(\.\d{1,2})?$/.test(num)) $.toptip('请输入充值金额！');
      else if (num>500) $.toast('充值金额大于500了哟！','text');
      else $.post('',{type:$('.weui-input').data('values'),num:num},function(res){
        bgMusic.play();//播放音效
        $.alert(res.msg);
      });
    });
  }) 
</script>
{/block}